package com.welkom.everydate.domain;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.springframework.security.core.GrantedAuthority;

import com.welkom.everydate.util.web.Header;

public class Role implements GrantedAuthority {
	@Header(headerText="角色编号")
	private long roleId;
	@Header(headerText="角色名称")
	private String roleName;
	
	private String roleDesc;
	@Header(headerText="角色状态")
	private int roleEnabled;
	@Header(headerText="角色默认路径")
	private String defaultRoleUrl;
	private List<Authority> authorities=new ArrayList<Authority>();
	
	public Role(long roleId, String roleName, String roleDesc,
			int roleEnabled,String defaultRoleUrl) {
		this.roleId = roleId;
		this.roleName = roleName;
		this.roleDesc = roleDesc;
		this.roleEnabled = roleEnabled;
		this.defaultRoleUrl=defaultRoleUrl;
	}
	public Role() {
		
	}
	/**
	 * @return the roleId
	 */
	public long getRoleId() {
		return roleId;
	}
	/**
	 * @param roleId the roleId to set
	 */
	public void setRoleId(long roleId) {
		this.roleId = roleId;
	}
	/**
	 * @return the roleName
	 */
	public String getRoleName() {
		return roleName;
	}
	/**
	 * @param roleName the roleName to set
	 */
	public void setRoleName(String roleName) {
		this.roleName = roleName;
	}
	/**
	 * @return the roleDesc
	 */
	public String getRoleDesc() {
		return roleDesc;
	}
	/**
	 * @param roleDesc the roleDesc to set
	 */
	public void setRoleDesc(String roleDesc) {
		this.roleDesc = roleDesc;
	}
	/**
	 * @return the roleEnabled
	 */
	public int getRoleEnabled() {
		return roleEnabled;
	}
	/**
	 * @param roleEnabled the roleEnabled to set
	 */
	public void setRoleEnabled(int roleEnabled) {
		this.roleEnabled = roleEnabled;
	}
	/**
	 * @return the authorities
	 */
	public List<Authority> getAuthorities() {
		return authorities;
	}
	/**
	 * @param authorities the authorities to set
	 */
	public void setAuthorities(List<Authority> authorities) {
		this.authorities = authorities;
	}
	
	
	public String getDefaultRoleUrl() {
		return defaultRoleUrl;
	}
	public void setDefaultRoleUrl(String defaultRoleUrl) {
		this.defaultRoleUrl = defaultRoleUrl;
	}
	@Override
	public boolean equals(Object object){
		if(!(object instanceof Role)){
			return false;
		}
		Role role=(Role)object;
		if(!(role.getRoleId()==this.getRoleId())){
			return false;
		}
		if(!(role.getRoleName().equals(this.getRoleName()))){
			return false;
		}
		return true;
	}
	@Override
	public int hashCode(){
		int result=17;
		result=31*result+(int)(roleId^(roleId>>>32));
		result=31*result+this.getRoleName().hashCode();
		return result;
	}
	@Override
	public String getAuthority() {
		// TODO Auto-generated method stub
		return this.getRoleName();
	}
}
